﻿using MCPlatform.UI.Controls.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace MCPlatform.UI.Controls.Views.MotionControl
{
    /// <summary>
    /// ImpMotion.xaml 的交互逻辑
    /// </summary>
    public partial class ImpMotion : UserControl
    {




        public ImpMotionModel ImpMotionModel
        {
            get { return (ImpMotionModel)GetValue(ImpMotionModelProperty); }
            set { SetValue(ImpMotionModelProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ImpMotionModel.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ImpMotionModelProperty =
            DependencyProperty.Register("ImpMotionModel", typeof(ImpMotionModel), typeof(ImpMotion), new PropertyMetadata(default));


        public ImpMotion()
        {
            InitializeComponent();
        }


        #region 按钮方法
        private void btn_Linear_Click(object sender, RoutedEventArgs e)
        {
            ImpMotionModel.ImputationEntity?.SetVelocity(ImpMotionModel.SetVelocity);
            if (ImpMotionModel.IsAbs) 
            {
                ImpMotionModel.ImputationEntity?.ImpLineAbsMove(ImpMotionModel.TargetPosition);
            }
            else
            {
                ImpMotionModel.ImputationEntity?.ImpLineRelMove(ImpMotionModel.TargetPosition);
            }

           
        }

        private void btn_Circular_Click(object sender, RoutedEventArgs e)
        {
            ImpMotionModel.ImputationEntity?.SetVelocity(ImpMotionModel.SetVelocity);
            if (ImpMotionModel.Radius > 0)
            {
                if (ImpMotionModel.IsAbs)
                {
                    ImpMotionModel.ImputationEntity?.ImpArcRediusAbsMove(ImpMotionModel.TargetPosition, ImpMotionModel.Radius, ImpMotionModel.ArcDir, ImpMotionModel.Circle);
                }
                else
                {
                    ImpMotionModel.ImputationEntity?.ImpArcRediusRelMove(ImpMotionModel.TargetPosition, ImpMotionModel.Radius, ImpMotionModel.ArcDir, ImpMotionModel.Circle);
                }
            }
            else
            {
                if (ImpMotionModel.IsAbs)
                {
                    ImpMotionModel.ImputationEntity?.ImpArc3PointAbsMove(ImpMotionModel.TargetPosition, ImpMotionModel.CenterPosition, ImpMotionModel.Circle);
                }
                else
                {
                    ImpMotionModel.ImputationEntity?.ImpArc3PointRelMove(ImpMotionModel.TargetPosition, ImpMotionModel.CenterPosition, ImpMotionModel.Circle);
                }
            }

            
        }

        private void btn_Elliptcal_Click(object sender, RoutedEventArgs e)
        {
            ImpMotionModel.ImputationEntity?.SetVelocity(ImpMotionModel.SetVelocity);
            if (ImpMotionModel.IsAbs)
            {
                ImpMotionModel.ImputationEntity?.ImpEllipseAbsMove(ImpMotionModel.TargetPosition, ImpMotionModel.CenterPosition, ImpMotionModel.Major, ImpMotionModel.Minor, ImpMotionModel.ArcDir);
            }
            else
            {
                ImpMotionModel.ImputationEntity?.ImpEllipseRelMove(ImpMotionModel.TargetPosition, ImpMotionModel.CenterPosition, ImpMotionModel.Major, ImpMotionModel.Minor, ImpMotionModel.ArcDir);
            }
        }

       



        private void btn_Stop_Click(object sender, RoutedEventArgs e)
        {
            ImpMotionModel.ImputationEntity?.StopMulticoor();
        }



        private void btn_Reset_Click(object sender, RoutedEventArgs e)
        {
            ImpMotionModel.ImputationEntity?.Reset();
        }


        #endregion


        #region utils Methods





        #endregion
    }
}
